package org.jrpc.common.utils;

import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
import org.jrpc.common.codec.MsgPackDecode;
import org.jrpc.common.codec.MsgPackEncode;

/**
 * Created by Administrator on 2017/8/28.
 */
public class ChannelUtil {
    public static void setChanneParam(SocketChannel ch){
        ch.pipeline().addLast("frameDecoder", new LengthFieldBasedFrameDecoder(65536, 0, 2, 0, 2));
        ch.pipeline().addLast("msgpack decoder",new MsgPackDecode());
        ch.pipeline().addLast("frameEncoder", new LengthFieldPrepender(2));
        ch.pipeline().addLast("msgpack encoder",new MsgPackEncode());
    }
}
